package com.storm.lib.vo;

import java.util.ArrayList;
import java.util.List;

import com.storm.lib.base.BaseVo;
import com.storm.lib.util.StringUtil;


//副本编号|难度,副本编号|难度@副本编号|难度
public class OrConditionNumberVo extends BaseVo{
	private IdNumberVo idNumberVo;
	private List<IdNumberVo> orConditions;
	
	public IdNumberVo getIdNumberVo() {
		return idNumberVo;
	}

	public void setIdNumberVo(IdNumberVo idNumberVo) {
		this.idNumberVo = idNumberVo;
	}

	public List<IdNumberVo> getOrConditions() {
		return orConditions;
	}

	public void setOrConditions(List<IdNumberVo> orConditions) {
		this.orConditions = orConditions;
	}

	public static List<OrConditionNumberVo> createList(String str){
		List<OrConditionNumberVo> list = new ArrayList<OrConditionNumberVo>();
		if(StringUtil.isEmpty(str)){
			return new ArrayList<OrConditionNumberVo>();
		}
		String[] vals = str.split(",");
		for (int i = 0; i < vals.length; i++) {
			OrConditionNumberVo orConditionNumberVo = new OrConditionNumberVo();
			if(vals[i].contains("@")){
				List<IdNumberVo> orConditions = new ArrayList<IdNumberVo>();
				String[] conditions = vals[i].split("@");
				for (int j = 0; j < conditions.length; j++) {
					String[] vals2= conditions[j].split("\\|");
					IdNumberVo idNumberVo = new IdNumberVo();
					idNumberVo.setId(Integer.valueOf(vals2[0]));
					idNumberVo.setNum(Integer.valueOf(vals2[1]));
					orConditions.add(idNumberVo);
				}
				orConditionNumberVo.orConditions=orConditions;
			}
			else{
				IdNumberVo idNumberVo = IdNumberVo.create(vals[i]);
				orConditionNumberVo.idNumberVo=idNumberVo;
			}
			list.add(orConditionNumberVo);
		}
		return list;
	}
}
